from pydantic_settings import BaseSettings
from pydantic import BaseModel
from functools import lru_cache

# fastapi最新推荐的配置文件读取


class MysqlSetting(BaseModel):
    sql_print: bool = True
    create_all_table: bool = False
    drop_all_table: bool = False

class ElasticSeachSetting(BaseModel):
    hpst: str
    port: int

class RedisSetting(BaseModel):
    host: str
    port: int

class KafkaSetting(BaseModel):
    host: str
    port: int

class BSetting(BaseModel):
    host: str
    port: int

class Settings(BaseSettings, MysqlSetting):
    app_name: str = "chf-app"
    database_url: str = 'mysql+aiomysql://root:chenhaifeng@42.194.198.29:3306/fastapi'
    secret: str = 'SECRET'

    class Config:
        env_file = ".env"


@lru_cache
def get_settings():
    return Settings()
